
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="/mobile/templates/blankPageTemp.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pm="http://primefaces.org/mobile" 
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j">

    <ui:define name="page">
        <pm:view id="clientData">
            <pm:header title="Przepustki">             
                <f:facet name="left"><p:button value="Wróć" icon="back" onclick="PrimeFaces.back()"/></f:facet>
            </pm:header>
      <p:growl autoUpdate="true" severity="info, error"/> 
            <pm:content>    

                <p:contextMenu for="frm:listTap" style="min-width:210px" >                                        
                    <h:form>  
                        <p:dataList type="inset">
                            <f:facet name="header" >Co chcesz zrobić?</f:facet>
                            <p:commandLink value="Wyświetl szczegóły" update=":display" oncomplete="PF('carDialog').show()"/>
                            <p:commandLink value="Edytuj pojazd" action="pm:wiz3"/>

                        </p:dataList>                     
                    </h:form>
                </p:contextMenu>                                             

                <h:form id="frm">


                    <p:dataList id="listTap"  value="#{parkingPassesBean.passesByClient}" var="pass"> 
                        <f:facet name="header" >Wybierz przepustkę</f:facet>                                                                                            
                        <h:outputLink value="#lists">                                         
                            <h2>#{pass.carId.numberPlate} na stanowisko   #{pass.numberId.number}</h2>                                                
                            <p><strong>Wydana: #{parkingPassesBean.getDateIS(pass)} Wygasa: #{parkingPassesBean.getDateExp(pass)}</strong></p> 
                        </h:outputLink>

                        <p:outputPanel>
                            <p:column>    
                                <p:commandLink styleClass="selection">
                                    <f:setPropertyActionListener value="#{pass}" target="#{parkingPassesBean.selectedPass}" />
                                </p:commandLink>                                                                            
                            </p:column>           
                        </p:outputPanel>    
                    </p:dataList>                
                </h:form>  
               


                   


                          
                <p:dialog header="Szczegóły przepustki" widgetVar="carDialog">  
                    <p:outputPanel id="display" style="text-align: center;min-width: 200px" >                        

                        <h:panelGrid columns="2">  
                            <h:outputText value="Marka:" />  
                            <h:outputText value="#{parkingPassesBean.selectedPass.carId.make}" style="font-weight:bold"/>  

                            <h:outputText value="Model:" />  
                            <h:outputText value="#{parkingPassesBean.selectedPass.carId.model}" style="font-weight:bold"/>  



                            <h:outputText value="Taryfa:" />  
                            <h:outputText value="#{parkingPassesBean.selectedPass.tarrif.name}" style="font-weight:bold"/>  

                            <h:outputText value="Cena:" />  
                            <h:outputText value="#{parkingPassesBean.selectedPass.tarrif.rank}" style="font-weight:bold"/>  


                        </h:panelGrid> 
                    </p:outputPanel>
                </p:dialog>                



            </pm:content>
        </pm:view>
  <pm:view id="wiz3">
            <pm:header title="Edycja">
                <f:facet name="left"><p:button value="Wróc" icon="back" onclick="PrimeFaces.back()"/></f:facet>
                <f:facet name="right"><p:button value="Anuluj" icon="delete" href="/mobile/index.xhtml"/></f:facet>
            </pm:header>
            <pm:content>
                <p:dataList type="inset">
                    <p:commandLink  action="pm:new" styleClass="selection" value="Dodaj nowy" >
                        <f:setPropertyActionListener value="2" target="#{parkingPassesBean.radioOptions}" />

                    </p:commandLink>                   

                    <p:commandLink  action="pm:old" styleClass="selection" value="Wybierz z istniejacych" >
                        <f:setPropertyActionListener value="1" target="#{parkingPassesBean.radioOptions}" />

                    </p:commandLink> 
                </p:dataList>

            </pm:content>
        </pm:view>   

        <pm:view id="new">
            <pm:header title="Nowy">
                <f:facet name="left"><p:button value="Wróc" icon="back" onclick="PrimeFaces.back()"/></f:facet>
            </pm:header>

            <pm:content>


                <h:form id="newCar">
                    <h:outputText value="#{bundle['passes.numberPlate']}"  />  

                    <p:inputText value="#{userWizard.carPlate}" placeholder="#{bundle['passes.plateTip']}" >
                        <f:validateLength maximum="10" />  
                    </p:inputText>

                    <h:outputText value="#{bundle['passes.make']}" />  

                    <p:inputText value="#{userWizard.carMake}" placeholder="#{bundle['passes.makeTip']}">
                        <f:validateLength maximum="20"  />  
                    </p:inputText>

                    <h:outputText value="#{bundle['passes.model']}" />  

                    <p:inputText value="#{userWizard.carModel}" placeholder="#{bundle['passes.modelTip']}" >
                        <f:validateLength maximum="50"  />  
                    </p:inputText>
                    <pm:field id="select">
                        <h:outputLabel  value="Typ pojazdu: "/>
                        <h:selectOneMenu required="true" value="#{parkingPassesBean.carType}" style="width: 100%;">  
                            <p:ajax event="change"  process="newCar"  update=":confNw">

                            </p:ajax>
                            <f:selectItem itemLabel="#{bundle['passes.choose']}"  itemValue=""/>  
                            <f:selectItem  itemLabel="#{bundle['car.typePersonal']}" itemValue="Personal"/>  
                            <f:selectItem itemLabel="#{bundle['car.typeTrailer']}" itemValue="Trailer"/>  
                            <f:selectItem  itemLabel="#{bundle['car.typeMotorcycle']}" itemValue="Motorcycle"/>  
                            <f:selectItem    itemLabel="#{bundle['car.typeVan']}" itemValue="Van"  />  


                        </h:selectOneMenu>  
                    </pm:field>
                </h:form>

                <p:button value="Dalej" href="#confNw?transition=slide" />
            </pm:content>
        </pm:view>

        <pm:view id="old">
            <pm:header title="Pojazd">
                <f:facet name="left"><p:button value="Wróc" icon="back" onclick="PrimeFaces.back()"/></f:facet>
                <f:facet name="right"><p:button value="Anuluj" icon="delete" href="/mobile/index.xhtml"/></f:facet>
            </pm:header>

            <pm:content>
                <h:form id="p3h">
                    <p:dataList id="listaS"  value="#{carBean.carsByClient}" var="car"> 
                        <f:facet name="header" >Wybierz jeden ze swoich pojazdów</f:facet>                                                                                            

                        <p:commandLink  action="pm:confSw" styleClass="selection" value="#{car.make} #{car.model} rejestracja:#{car.numberPlate}" update=":confSw">
                            <f:setPropertyActionListener value="#{car.carId}" target="#{parkingPassesBean.chosenCar}" />
                            
                        </p:commandLink>    

                    
                           


                    </p:dataList>                
                </h:form>
            </pm:content>
        </pm:view>   
        
         <pm:view id="confSw">
            <pm:header title="Pojaz">
                <f:facet name="left"><p:button value="Wróc" icon="back" onclick="PrimeFaces.back()"/></f:facet>
                <f:facet name="right"><p:button value="Anuluj" icon="delete" href="/mobile/index.xhtml"/></f:facet>
            </pm:header>

            <pm:content>
                         <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel value="#{bundle['passes.make']}" />  
                    <h:outputText value="#{parkingPassesBean.chosenCarM.make}" />  

                                    <h:outputLabel value="#{bundle['passes.model']}" />  
                                    <h:outputText value="#{parkingPassesBean.chosenCarM.model}"/>  


                                    <h:outputLabel value="#{bundle['passes.numberPlate']}" />  
                                    <h:outputText value="#{parkingPassesBean.chosenCarM.numberPlate}"/> 
                                    <h:outputLabel value="#{bundle['passes.carType']}" />  
                                    <h:outputText value="#{parkingPassesBean.carTypeForUser}"/>  
                                      </h:panelGrid>
                <p:commandButton id="submitButtonSw" action="pm:clientData" value="Zapisz" update=":clientData" actionListener="#{parkingPassesBean.updateCarinParkingPasses}"/>  
            </pm:content>


        </pm:view>
                <pm:view id="confNw">
            <pm:header title="Potw">
                <f:facet name="left"><p:button value="Wróc" icon="back" onclick="PrimeFaces.back()"/></f:facet>
                <f:facet name="right"><p:button value="Anuluj" icon="delete" href="/mobile/index.xhtml"/></f:facet>
            </pm:header>

            <pm:content>
                <p:growl  id="s" autoUpdate="true" severity="info, error"/> 
                 <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel value="#{bundle['passes.make']}" />  
                    <h:outputText value="#{parkingPassesBean.make}" />  

                                    <h:outputLabel value="#{bundle['passes.model']}" />  
                                    <h:outputText value="#{parkingPassesBean.model}"/>  


                                    <h:outputLabel value="#{bundle['passes.numberPlate']}" />  
                                    <h:outputText value="#{parkingPassesBean.plate}"/> 
                                    <h:outputLabel value="#{bundle['passes.carType']}" />  
                                    <h:outputText value="#{parkingPassesBean.carTypeForUser}"/>  
                                          </h:panelGrid>
                <p:commandButton id="submitButton" action="pm:clientData" value="Zapisz" update=":clientData, s" actionListener="#{parkingPassesBean.updateCarinParkingPasses}"/>  
            </pm:content>


        </pm:view>  
    </ui:define>
</ui:composition>